package com.tianji.remark.controller;

import com.tianji.remark.pojo.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 点赞记录表 控制器
 * </p>
 *
 * @author xjs
 */
@Api(tags = "LikedRecord管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/likes")
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;

    @ApiOperation("点赞或者取消点赞")
    @PostMapping
    public void likeOrUnlike(@RequestBody LikeRecordFormDTO dto){

        likedRecordService.likeOrUnlike(dto);
    }

    @ApiOperation("feign接口，根据多个业务id查询是否点赞")
    @GetMapping("/list")
    public List<String> list(@RequestParam("bizIds")List<Long> bizIds,
                             @RequestParam(required = false, defaultValue = "QA") String bizType){
        return likedRecordService.listLikeRecords(bizIds, bizType);
    }

}
